package cn.zhf.shop.controller;

import cn.zhf.shop.entity.Ad;
import cn.zhf.shop.entity.Bank;
import cn.zhf.shop.entity.Message;
import cn.zhf.shop.service.AdService;
import cn.zhf.shop.service.BankService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/bank")
@Api(tags = "银行管理")
public class BankController {
    @Resource
    private BankService bankService;

    @ApiOperation(value = "添加银行")
    @PostMapping("/append")
    public Message appendAd(Bank bank){
        return bankService.insert(bank);
    }

    @ApiOperation(value = "删除银行")
    @GetMapping("/remover")
    public Message removeAd(int id){
        return bankService.deleteByPrimaryKey(id);
    }

    @ApiOperation(value = "修改银行")
    @GetMapping("/update")
    public Message updateAd(Bank bank){
        return bankService.updateByPrimaryKey(bank);
    }

    @ApiOperation(value = "查询所有银行")
    @GetMapping("/all")
    public Message<List<Bank>> getAll(){
        return bankService.selectAll();
    }

    @ApiOperation(value = "根据id查找银行")
    @GetMapping("/")
    public Message<Bank> getAd(int id){
        return bankService.selectByPrimaryKey(id);
    }

    @ApiOperation(value = "模糊查询")
    @GetMapping("/search1")
    public Message<List<Bank>> search1(String str){
        return bankService.search1(str);
    }
}
